package com.muyu.product.controller;

import com.muyu.common.core.domain.R;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.product.domain.vo.ProductTypeVo;
import com.muyu.product.service.TypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName TypeController
 * @Description 描述
 * @Author ShiYu.Cui
 * @Date 2024/3/31 10:00
 */
@RestController
@RequestMapping("product/type")
@Api(tags = "商品类型管理")
public class TypeController extends BaseController {
    @Autowired
    private TypeService typeService;
    @GetMapping("/typeList")
    @ApiOperation("获取商品全部类型")
    public R<List<ProductTypeVo>> typeList(){
        return typeService.typeList();
    }

    @PostMapping("/addType")
    @ApiOperation("添加商品类型")
    public R addType(@RequestBody ProductTypeVo productTypeVo){
        typeService.addType(productTypeVo);
        return R.ok();
    }

    @PostMapping("/updateType")
    @ApiOperation("修改商品类型")
    public R updateType(@RequestBody ProductTypeVo productTypeVo){
        typeService.updateType(productTypeVo);
        return R.ok();
    }


    @GetMapping("/delType")
    @ApiOperation("删除商品类型")
    public R delType(@RequestParam Integer productTypeId){
        typeService.delType(productTypeId);
        return R.ok();
    }
}

